package com.test;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        String contentKey = "abcde123";
        final MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(contentKey.getBytes());
        final byte byteData[] = md.digest();

        final StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16)
                    .substring(1));
        }

        final byte[] encodedBytes = Base64.getEncoder()
                .encode(sb.toString().getBytes());

        String result = URLEncoder.encode(new String(encodedBytes), "UTF-8");
        System.out.println(result);
    }
}
